package com.roy.reversi.view;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.roy.reversi.controller.Controller;

public class ContainPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	private ImageIcon ic = new ImageIcon("res/bg.jpg");
	
	private GamePanel gamePanel;
	private ControlPanel controlPanel;

	private Controller controller;
	private JLabel jlInfo;
	
	public ContainPanel(){
		setSize(ic.getIconWidth(), ic.getIconHeight());
		this.setLayout(null);
		
		controller = new Controller();
		
		gamePanel = new GamePanel(controller);
		gamePanel.setContailPanel(this);
		
		controlPanel = new ControlPanel(controller);
		
		controller.setGamePanel(gamePanel);
		controller.setControlPanel(controlPanel);
		
		gamePanel.setLocation(5, 5);
		add(gamePanel);
		
		controlPanel.setLocation(gamePanel.getWidth() + 7, 5);
		add(controlPanel);
		
		jlInfo = new JLabel();
		jlInfo.setForeground(Color.BLUE);
		jlInfo.setBounds(10, gamePanel.getHeight() + 5, gamePanel.getWidth(), 20);
		
		add(jlInfo);
	}

	@Override
	protected void paintComponent(Graphics g) {
		g.drawImage(ic.getImage(), 0, 0, null);
	}
	
	public void setInfo(String info){
		jlInfo.setText(info);
	}
	

}
